package com.timsmeet.timeperiod;

import java.util.Calendar;
import java.util.GregorianCalendar;

import com.timsmeet.utils.ArgumentValidator;

public class TimePeriodUtils {

	public static Calendar trimCalendar(Calendar calendar) {
		ArgumentValidator.isNotNull(calendar, "calendar");
		
		return new GregorianCalendar(
				calendar.get(Calendar.YEAR),
				calendar.get(Calendar.MONTH),
				calendar.get(Calendar.DAY_OF_MONTH),
				calendar.get(Calendar.HOUR_OF_DAY),
				calendar.get(Calendar.MINUTE));
	}
	
	public static int compareTrimedCalendar(Calendar calendar1, Calendar calendar2) {
		ArgumentValidator.isNotNull(calendar1, "calendar1");
		ArgumentValidator.isNotNull(calendar2, "calendar2");
		
		calendar1 = trimCalendar(calendar1);
		calendar2 = trimCalendar(calendar2);
		
		return calendar1.compareTo(calendar2);
	}
}
